DetXofKinN <- function(N) {
  
  # Initialize
  K = min(N,20)
  NKX <- matrix( numeric(K*K),K,K)
  NK  <- integer(K)
  Combos <- list("NK"=NK,"NKX"=NKX)
  
  for (k in 1:K) {
    NK[k] = choose(N,k)
    for (x in 1:k) {
      NKX[k,x] <- sum(combn(N,k,function(NcK) sum(NcK <= x)==x))
      print(paste("Done with k=",as.character(k),"and x=",as.character(x)))
    }
  }
  
#   for (k in 1:K) {
#     NcK <- combn(N,k)
#     dimNcK <- dim(NcK)
#     NK[k] <- dimNcK[2]
#     for (x in 1:k) {
#       total <- sum(colSums(NcK <= x) == x)
#       NKX[k,x] = total
#       print(paste("Done with k=",as.character(k),"and x=",as.character(x)))
#     }
#   }

  Combos$NK  = NK
  Combos$NKX = NKX
  return(Combos)
}